package top.hidoctor.auscultation.feature.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.Window;
import android.view.WindowManager;

import com.tang.user.UserInfoManager;

import top.hidoctor.auscultation.MainActivity;
import top.hidoctor.auscultation.R;
import top.hidoctor.auscultation.base.BaseActivity;

public class SplashActivty extends BaseActivity {
    private Handler handler = new Handler();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //无title
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        //全屏
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_splash);
        jumpTo();
    }

    private void jumpTo() {
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (TextUtils.isEmpty(UserInfoManager.getInstance().getToken())) {
                    startActivity(new Intent(SplashActivty.this, LoginActivity.class));
                } else {
                    startActivity(new Intent(SplashActivty.this, MainActivity.class));
                }
                finish();
            }
        }, 1000);

    }
}
